import React from 'react';
import { Route, IndexRoute } from 'react-router';

import App from './containers/App';
import Root from './containers/Root';
import LoginPage from './components/login/LoginPage';
import SignupPage from './components/signup/SignupPage';
import ProfilePage from './components/profile/ProfilePage';

import { AdminPage,AdminLoginPage,AdminDashboard,AdminUserContainer,GroupPage,AdminGroupForm,TagPage,TagForm} from './containers/admin'  ;  
import { AdminItembankPage,AddItembankPage,QuestionPage,AddQuestionForm,AdminUserForm} from './components/admin' ; 
import NotFound from './containers/notfound/NotFound' ;
import  { requireAuth } from './utils/auth' ; 

export default (
  <Route component={Root} >
      <Route path="/" component={App} >
        <IndexRoute component={LoginPage} />
        <Route path="login" component={LoginPage} />
        <Route path="signup" component={SignupPage} />
        <Route path="profile" component={ProfilePage} />
      </Route>
      <Route path="admin" component={AdminPage}  onEnter={requireAuth} >
        <Route path="dashboard" component={AdminDashboard} />
        <Route path="itembank" component={AdminItembankPage} />
        <Route path="itembank/new"  component={AddItembankPage}/>
        <Route path="itembank/:id" component={AddItembankPage} />
        <Route path="users" component={AdminUserContainer} />
        <Route path="users/add" component={AdminUserForm} />
        <Route path="users/:id" component={AdminUserForm} />
        <Route path="groups" component={GroupPage} />
        <Route path="groups/add" component={AdminGroupForm} />
        <Route path="groups/:id" component={AdminGroupForm} />
        
        <Route path="tags" component={TagPage} />
        <Route path="tags/add" component={TagForm} />
        <Route path="tags/:id" component={TagForm} />

        <Route path="questions" component={QuestionPage} />
        <Route path="questions/add" component={AddQuestionForm} />
        <Route path="questions/:id" component={AddQuestionForm} />
      </Route>
      <Route path="/backend/login" component={AdminLoginPage} />
      <Route path="*" component={NotFound} />
  </Route>
)